package com.viphuli.app.tool.handler;

import android.view.View;

import com.viphuli.app.tool.R;
import com.viphuli.app.tool.bean.page.AccountRemindPage;
import com.viphuli.app.tool.bean.part.AccountRemind;
import com.viphuli.app.tool.fragment.AccountRemindFragment;

public class AccountRemindInfoResponseHandler extends MyBaseHttpResponseHandler<AccountRemindFragment, AccountRemindPage> {

	@Override
	public void deal() {

		AccountRemind remind = page.getRemind();

		if (remind != null) {

			if (remind.isSwitching())
				caller.getRemindSwitchView().setBackgroundResource(R.drawable.ic_switch_on);
			else
				caller.getRemindSwitchView().setBackgroundResource(R.drawable.ic_switch_off);

			int minutes = remind.getAheadMinutes();
			int hour = minutes / 60;
			int minute = minutes % 60;

			caller.getTimeDescText().setText("提前" + hour + "小时" + minute + "分");

			caller.getRemindMsgView().setText(remind.getMsg());
			 
			if (remind.isSwitching()) {
				caller.getRemindTimeView().setVisibility(View.VISIBLE);
			} else
				caller.getRemindTimeView().setVisibility(View.GONE);

		} else {//为空时给个默认的

			remind = new AccountRemind();
		}

		//更新状态值
		caller.setRemind(remind);

	}
}
